//
//  ZYAlreadyAgreedCell.m
//  BestLearning
//
//  Created by Ethan on 2017/9/26.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "ZYAlreadyAgreedCell.h"
#import "ZYAlreadyAgreedModel.h"
@implementation ZYAlreadyAgreedCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    return self;
    
}

- (void)assignByZYAlreadyAgreedModel:(ZYAlreadyAgreedModel *)model{


    
    NSMutableAttributedString *hintString=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"约定课程  %@",[model.trainLesson valueForKey:@"name"]]];
    //获取要调整颜色的文字位置,调整颜色
    NSRange range1=[[hintString string]rangeOfString:@"约定课程"];
    [hintString addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:range1];
    
    self.courseNameLabel.attributedText=hintString;
    
    
    
    
    
    
    
    
    
    NSMutableAttributedString *hintStringTow=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"约定要素  %@",[model.setCourseComment valueForKey:@"content"]]];
    //获取要调整颜色的文字位置,调整颜色
    NSRange rangeTow=[[hintStringTow string]rangeOfString:@"约定要素"];
    [hintStringTow addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:rangeTow];
    
    self.essentialFactorLabel.attributedText=hintStringTow;
    
    
    
    
    
    
    
    
    
    
    
    
    
    NSMutableAttributedString *hintStringThree=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"约定目标  %@个优",model.target]];
    //获取要调整颜色的文字位置,调整颜色
    NSRange rangeThree=[[hintStringThree string]rangeOfString:@"约定目标"];
    [hintStringThree addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:rangeThree];
    
    self.agreedContentLabel.attributedText=hintStringThree;
    
    
    
    
    
    
    
    self.completionAwardLabel.text = [NSString stringWithFormat:@"%@",model.content];
    
    
    NSMutableAttributedString *hintStringFour=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"完成奖励  %@",model.content]];
    //获取要调整颜色的文字位置,调整颜色
    NSRange rangeFour=[[hintStringFour string]rangeOfString:@"完成奖励"];
    [hintStringFour addAttribute:NSForegroundColorAttributeName value:ColorRGB(153,153,153) range:rangeFour];
    
    self.completionAwardLabel.attributedText=hintStringFour;
    
    
    
    
    
    
    
    
    //0待处理；1已同意；2未同意；3待兑换；4已兑换；
    
    if (0== [model.status integerValue]) {
         [self.exchangeTypeButton setTitle:@"待处理" forState:(UIControlStateNormal)];
    }else if (1 == [model.status integerValue]){
         [self.exchangeTypeButton setTitle:@"已同意" forState:(UIControlStateNormal)];
    }else if (2 == [model.status integerValue]){
        [self.exchangeTypeButton setTitle:@"未同意" forState:(UIControlStateNormal)];
    }else if (3 == [model.status integerValue]){
        [self.exchangeTypeButton setTitle:@"待兑换" forState:(UIControlStateNormal)];
    }
    else{
       
         [self.exchangeTypeButton setTitle:@"已兑换" forState:(UIControlStateNormal)];
        
        
    }
    
    
    
}











- (void)setUpSuperView{
    
//    @property (nonatomic,strong) UILabel *courseNameLabel;//课程名
//    @property (nonatomic,strong) UILabel *essentialFactorLabel;//要素名
//    @property (nonatomic,strong) UILabel *agreedContentLabel;//约定内容
//    @property (nonatomic,strong) UIButton *exchangeTypeButton;//兑换类型
    
    self.courseNameLabel = [UILabel new];
    self.courseNameLabel.textColor = ColorRGB(0, 0, 0);
    self.courseNameLabel.font = [UIFont systemFontOfSize:14];
    self.courseNameLabel.numberOfLines = 0;
    [self.contentView addSubview:self.courseNameLabel];
    
    self.essentialFactorLabel = [UILabel new];
    self.essentialFactorLabel.textColor = ColorRGB(0, 0, 0);
    self.essentialFactorLabel.font = [UIFont systemFontOfSize:14];
     self.essentialFactorLabel.numberOfLines = 0;
    [self.contentView addSubview:self.essentialFactorLabel];
    
    
    self.agreedContentLabel = [UILabel new];
    self.agreedContentLabel.textColor = ColorRGB(0, 0, 0);
    self.agreedContentLabel.font = [UIFont systemFontOfSize:14];
    self.agreedContentLabel.numberOfLines = 0;
    [self.contentView addSubview:self.agreedContentLabel];
    
    self.completionAwardLabel = [UILabel new];
    self.completionAwardLabel.textColor = ColorRGB(0, 0, 0);
    self.completionAwardLabel.font = [UIFont systemFontOfSize:14];
    self.completionAwardLabel.numberOfLines = 0;
    [self.contentView addSubview:self.completionAwardLabel];
    
    
    self.exchangeTypeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.exchangeTypeButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.exchangeTypeButton setTitleColor:ColorRGB(118,187,252) forState:(UIControlStateNormal)];
    [self.contentView addSubview:self.exchangeTypeButton];
    
    
    
    self.courseNameLabel.text = @"约定课程：舍利子";
    [self.courseNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(8);
        make.right.equalTo(self).offset(-8);
        
    }];
    
    
    UILabel *grayOne = [UILabel new];
    grayOne.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayOne];
    
    [grayOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.courseNameLabel.mas_bottom).offset(5);
        make.width.offset(kScreenWidth);
        make.height.offset(1);
    }];
    
    
    
    self.essentialFactorLabel.text = @"约定要素：舍利子, 是诸法空相, 不生不灭, 不垢不净, 不增不减";
    [self.essentialFactorLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(grayOne.mas_bottom).offset(8);
        make.left.equalTo(self.courseNameLabel);
         make.right.equalTo(self).offset(-8);
        
    }];
    
    
    UILabel *grayTow = [UILabel new];
    grayTow.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayTow];
    
    [grayTow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.essentialFactorLabel.mas_bottom).offset(5);
        make.width.offset(kScreenWidth);
        make.height.offset(1);
    }];
    
    
    
    
    self.agreedContentLabel.text= @"约定目标：舍利子, 是诸法空相, 不生不灭, 不垢不净, 不增不减";
    [self.agreedContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.essentialFactorLabel);
        make.top.equalTo(grayTow.mas_bottom).offset(8);
         make.right.equalTo(self).offset(-8);
    }];
    
    
    UILabel *grayThree = [UILabel new];
    grayThree.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayThree];
    
    [grayThree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.agreedContentLabel.mas_bottom).offset(5);
        make.width.offset(kScreenWidth);
        make.height.offset(1);
    }];
    
    
    
    [self.completionAwardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.agreedContentLabel);
        make.top.equalTo(grayThree.mas_bottom).offset(8);
         make.right.equalTo(self).offset(-8);
        
    }];
    
   
    [self.exchangeTypeButton  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-8);
        make.top.equalTo(self.completionAwardLabel.mas_bottom).offset(8);
        
    }];
    
    
    
    
    UILabel *grayFour= [UILabel new];
    grayFour.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:grayFour];
    
    
    [grayFour mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.exchangeTypeButton.mas_bottom).offset(10);
        make.width.offset(kScreenWidth);
        make.height.offset(15);
    }];
    
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.offset(0);
        make.bottom.mas_equalTo(grayFour.mas_bottom).offset(0);
        
    }];
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}






























@end
